package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.db.BlackList;
import com.tanhua.model.db.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class BlackListApiImpl implements BlackListApi {
    @Autowired
    private BlackListMapper blackListMapper;
  @Autowired
  private UserInfoMapper userInfoMapper;
    @Override
    public IPage<UserInfo> selectBlackList(Long userId, Integer page, Integer pageSize) {
        //构造分页参数
        Page<UserInfo> pageParam = new Page<>(page,pageSize);
        return userInfoMapper.findBlackList(pageParam,userId);

    }

    @Override
    public void delBlack(Long blackId, Long userId) {
        LambdaQueryWrapper<BlackList> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BlackList::getBlackUserId,blackId);
        wrapper.eq(BlackList::getUserId,userId);
        blackListMapper.delete(wrapper);
    }
}
